import { configureStore } from "@reduxjs/toolkit";
import counterSlice from "./modules/counter";
import recommendSlice from "@/views/discover/c-views/recommend/store";
import { useSelector, TypedUseSelectorHook, useDispatch, shallowEqual } from "react-redux";

const store = configureStore({
  reducer: {
    counter: counterSlice,
    recommend: recommendSlice,
  },
});
type GetStateFnType = typeof store.getState;
type DispatchType = typeof store.dispatch;

export type IRootState = ReturnType<GetStateFnType>;

export const useAppSelector: TypedUseSelectorHook<IRootState> = useSelector;

export const useAppDispatch: () => DispatchType = useDispatch;

export const appShallowEqual = shallowEqual;
export default store;
